<?php include PATH_TPL."/admin/tpl.header.phtml"?>
<div class="main-container inner">
    <div class="main-content">
        <div class="container-fluid">
            <div class="row bt">
                <div class="col-lg-12 bg">
                    <ol class="breadcrumb">
                        <li class="active">
                            <i class="fa  fa-fw fa-reorder"></i>审核详情
                        </li>
                    </ol>
                </div>
            </div>
            <div id="page-wrapper">
                <div class="container-fluid col-md-12 col-sx-12">
                    <form name='myform'>
                        <div>
                           <i class="glyphicon glyphicon-ok orange hidden" id="ok"></i>&nbsp;&nbsp;<input type="button" class="btn btn-success" value="审核通过" name="adoptBtn" style="height:20px;line-height:8px;width:80px;"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                           <i class="glyphicon glyphicon-remove hidden" id="remove"></i>&nbsp;&nbsp;<input type="button" class="btn btn-success" value="有问题" name="issueBtn" style="height:20px;line-height:8px;width:80px;"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                           <i class="glyphicon glyphicon-remove hidden" id="failed"></i>&nbsp;&nbsp;<input type="button" class="btn btn-success" value="审核不通过" name="failedBtn" style="height:20px;line-height:8px;width:100px;"/>&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" value="" placeholder="请输入不通过原因" name="failedreason" class="reason"/>
                        </div>
                        <div class="form-group ">
                            <label><strong>姓名</strong></label></br>
                            <label><?=$tUCRow['username']?></label>
                        </div>
                        <div class="form-group ">
                            <label><strong>证件类型</strong></label></br>
                            <label><?=$tURow['crittype_info']?></label>
                        </div>
                         <div class="form-group ">
                            <label><strong>证件号码</strong></label></br>
                            <label><?=$tURow['critcode']?></label>
                        </div>
                         <div class="form-group ">
                            <label><strong>保险公司</strong></label></br>
                            <label><?=$tUCRow['insurance_name']?></label>
                        </div>
                         <div class="form-group ">
                            <label><strong>投保单位</strong></label></br>
                            <label><?=$tUCRow['policyname']?></label>
                        </div>
                         <div class="form-group ">
                            <label><strong>用户等级</strong></label></br>
                            <label id='vipLabel'><?=$tInsuredgradeRow[$tUCRow['insuredgrade']]?><?if($tUCRow['insuredgrade'] == 0){?><a href="#" onclick="temporaryVip(<?=$tCaseID?>)">设置临时VIP</a><?}?></label>
                        </div>
                         <div class="form-group ">
                            <label><strong>审核状态</strong></label></br>
                            <label><?=$tStatusRow[$tUCRow['status']]?></label>
                        </div>

                        <div class="form-group">
                            <label for="img"><strong>提交资料</strong></label>
                        </div>
                        <div>
                            <?foreach($tDataTypeList as $tKey => $tDatas){
?>
                                <div>
                                    <label><?=$tDataTypeRow[$tKey]?><?php if(!empty(strstr($tBDatatype,$tKey))){echo '(必选项)';}?></label>
                                    <div class="form-group ">
                                        <label>是否通过<label>
                                        <label>
                                            <input type="radio" value="1" name="issue[<?=$tKey?>]"class="true" checked /> 是
                                            <input type="radio" value="0" name="issue[<?=$tKey?>]" class="false" /> 否
                                            <input type="text" value="" placeholder="请输入问题原因" name="introduce[<?=$tKey?>]" class="reason hidden"/>
                                        </label>
                                    </div>
                                    <div class="row">
                                        <?if(isset($tFLDatas[$tKey])){?>
                                        <div>问题原因</div>
                                        <?foreach($tFLDatas[$tKey] as $tRow){?> 
                                        <p><?=date('Y-m-d H:i:s',$tRow['created'])?> <?=$tRow['introduce']?></p>
                                        <?}?>
                                        <?}?>
                                    </div>
                                    <div class="row">
                                        <?foreach($tDatas as $tRow){?>
                                        <div class="col-md-3" style="position:relative" class="imgDiv">
                                            <?if(isset($tUCNArr[$tKey]) && in_array($tRow['dt_id'],$tUCNArr[$tKey])){?><span class="label label-info">NEW</span><?}?>
                                            <?if(isset($tCHIData[$tRow['datatype']]) && in_array($tRow['dt_id'],$tCHIData[$tRow['datatype']])){?>
                                            <a class="thumbnail">
                                            <img data-original="<?=$tRow['img']?>" src="<?=$tRow['img_small']?>" alt="...">
                                            </a>

                                            <span aria-hidden="true" class="glyphicon glyphicon-ok icon" style="position:absolute;color:red;font-size:30px;"></span>
                                            <?}else{?>
                                            <a class="thumbnail">
                                            <img data-original="<?=$tRow['img']?>" src="<?=$tRow['img_small']?>" alt="...">
                                            <input type="hidden" value="0" name="imgurl[<?=$tKey?>][<?=$tRow['dt_id']?>]"  />
                                            <span class="btn btn-orange imgbtn " style="margin-left:23%;height:20px;width:120px;font-size:12px;line-height:10px;opacity:0.5;color:black;margin-top:0px;" name="big">打包</span>
                                            </a>

                                            <span aria-hidden="true" class="glyphicon glyphicon-ok icon" style="position:absolute;color:red;font-size:30px;display:none" data="choose"></span>
                                            <input type="hidden" value="0" name="imgurl[<?=$tKey?>][<?=$tRow['dt_id']?>]"  />
                                            <?}?>
                                        </div>
                                        <?}?>
                                    </div>
                                </div>
                            <?}?>
                        </div>
                        <div class="form-group">
                            <label><strong>状态时间</strong></label></br>
                            <table>
                                <tbody>
                                    <?foreach($tUCLDatas as $tRow){?>
                                    <tr>
                                    <td><?=$tRow['title']?></td>
                                    <td><?=date('Y.m.d H:i',$tRow['created'])?></td>

                                    </tr>
                                    <?}?>
                                </tbody>
                            </table>
                        </div>
                        <input type="hidden" name="case_id" value="<?=$tCaseID?>" /> 
                    </form>
                </div>
                <div class="container-fluid col-md-5">
                    <div class="images text-center" id="img_view">
                    </div>
                </div>
            </div>
        </div>
        <div class="subviews">
            <div class="subviews-container"></div>
        </div>
    </div>
    <!-- end: PAGE -->
</div>

<script>
$(function(){
		Array.prototype.indexOf = function(val) { for (var i = 0; i < this.length; i++) { if (this[i] == val) return i; } return -1; };
		Array.prototype.remove = function(val) { var index = this.indexOf(val); if (index > -1) { this.splice(index, 1); } };
        var caseID = GetQuery('case_id');
		var c = GetQuery('c');//接收过来的案件id组成的字符串
		var cc = c.split(",");//拆分成数组
		$('input[name="issueBtn"]').click(function(){
        $('#remove').removeClass('hidden');
        var data = $('form[name="myform"]').serialize();
		$.post('/admin_case/issueopt',data,function(obj){
            if(obj.status == 0){alert(obj.msg);return;}
			if(confirm(obj.msg)){
				for(var i=0;i<cc.length;i++){
					if(caseID == c){
						alert('这已经是最后一个案件了,即将跳转到案件审核列表');location.href="/admin_case/";return;
					}
					if(caseID == cc[i]){
						cc.remove(caseID);
						location.href="/admin_case/detail?case_id="+cc[0]+"&c="+cc.join(",");		
					}
				}
					
			}else{
				location.href="/admin_case";
			};     
        });
    });
		$('input[name="failedBtn"]').click(function(){
		var failedreason = $('input[name="failedreason"]').val();
        $('input[name="failedreason"]').removeClass('hidden');
		$('#failed').removeClass('hidden');
        //var data = $('form[name="myform"]').serialize();
		//var data = caseID;
		if(failedreason){
		$.post('/admin_case/failed',{ 'case_id':caseID,'failedreason':failedreason },function(obj){
            if(obj.status == 0){alert(obj.msg);return;}
			if(confirm(obj.msg)){
				for(var i=0;i<cc.length;i++){
					if(caseID == c){
						alert('这已经是最后一个案件了,即将跳转到案件审核列表');location.href="/admin_case/";return;
					}
					if(caseID == cc[i]){
						cc.remove(caseID);
						location.href="/admin_case/detail?case_id="+cc[0]+"&c="+cc.join(",");		
					}
				}
					
			}else{
				location.href="/admin_case";
			};     
        });
		}else{alert('请填写不通过原因');return;}
    });
        $('input[name="adoptBtn"]').click(function(){
          //      var a = [];
            //    $('a[class="thumbnail"] img').each(function(){
              //      a.push($(this).attr('src'));
             //   });
            //    console.log(a);
            //if($('span[data="choose"]').css('display','none')){
              //  alert('您有分类未选择图片！');return;
            //}
       $('#ok').removeClass('hidden'); 
        var data = $('form[name="myform"]').serialize();
        $.post('/admin_case/adopt',data,function(obj){
            /*alert(obj.msg); 
            if(obj.status == 1){
                window.location.reload(); 
            }*/
            if(obj.status == 0){alert(obj.msg);return;}
			if(confirm(obj.msg)){
				for(var i=0;i<cc.length;i++){
					if(caseID == c){
						alert('这已经是最后一个案件了,即将跳转到案件审核列表');location.href="/admin_case/";return;
					}
					if(caseID == cc[i]){
						cc.remove(caseID);
						location.href="/admin_case/detail?case_id="+cc[0]+"&c="+cc.join(",");		
					}
				}
					
			}else{
				location.href="/admin_case";
			};     
        })
    });
    $('.imgbtn').click(function(){
        $('input[name="failedreason"]').removeClass('hidden');
		var obj = $(this).parent().parent();
        var status = obj.children('.icon').css('display');
        if(status == 'none'){
            obj.children('.icon').css('display','block'); 
            obj.children('input[type="hidden"]').attr('value',1);
        }else{
            obj.children('.icon').css('display','none'); 
            obj.children('input[type="hidden"]').attr('value',0);

        }
    });
    $('.row').viewer({
        url:'data-original',
    });
    $('img').mouseover(function() {
        $(this).css('cursor','pointer');
//        $(this).siblings('span[name="big"]').removeClass('hidden');
    }).mouseout(function() {
 //       $('span[name="big"]').addClass('hidden');
    });
})
function temporaryVip(case_id){
    $.get('/admin_case/temporaryVip?case_id='+case_id,function(obj){
        alert(obj.msg); 
        if(obj.status == 1){
            $('#vipLabel').html('临时VIP'); 
        }
    });
}
/*获取地址栏参数*/
function GetQuery(key) {
	var search = location.search.slice(1); //得到get方式提交的查询字符串
	var arr = search.split("&");
	for (var i = 0; i < arr.length; i++) {
        var ar = arr[i].split("=");
        if (ar[0] == key) {
            return ar[1];
        }
	}
}
$('input[class="false"]').click(function(){
        $('input[value="审核通过"]').attr('disabled',true);
});
$('input[class="true"]').click(function(){
        $('input[value="审核通过"]').attr('disabled',false);
});
$('input[class="false"]').each(function(){
    $(this).click(function(){
        $(this).siblings('input[class="reason hidden"]').removeClass('hidden');
    });
});
$('input[class="true"]').each(function(){
    $(this).click(function(){
        $(this).siblings('input[class="reason"]').addClass('hidden');
    });
});
</script>

<?php include PATH_TPL."/admin/tpl.footer.phtml"?>
